<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

/**
 * 首页控制器
 * 
 * Enter description here ...
 * @author Administrator
 *
 */

/**
 * 注意各个函数返回值是反的，为真表示有错误
 * Enter description here ...
 * @author Administrator
 *
 */
class Validator_str  
{
    public function username_admin($str)
    {
        if (preg_match('#^(admin|root)#i', $str))
            return '%s不能以admin等特殊单词开头';
        return false;    
        
    }
    
    public function username_exists($username, $password)
    {
        $ci = & get_instance();
        $ci->db->select('count(*) as count1')
               ->from('member')
               ->where(array('username' => $username))
               ->where(array('password' => sha1($password)));
        $query = $ci->db->get();
        $result = $query->row()->count1;
     //   $ci->log4php->debug($result);
        
        if (!$result)
            return '用户名和密码错误';
        return false;    
        
    }
	
}

